<template>
  <div
    @click="contentClick(routeName)"
    class="content"
    :class="{ active: $route.path === routeName }"
  >
    <span>{{ title }}</span>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";

const props = defineProps({
  title: {
    type: String,
    default: () => "默认标题",
  },
  routeName: {
    type: String,
    default: () => "/",
  },
});

const router = useRouter();
const contentClick = (route) => {
  router.push(route);
};
</script>

<style lang="less" scoped>
.content {
  z-index: 10;
  height: 40px;
  text-align: center;
  font-size: 18px;
  line-height: 40px;
  color: #000;
  span {
    cursor: pointer;

    // &:hover {
    //   color: #ea0000;
    // }
  }
}
.active {
  height: 40px;
  background-color: #427bff9c;
  color: #fff;
  border-radius: 20px;

  // &:hover {
  //   color: #000;
  // }
}
</style>